#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>

#include <sys/select.h>
#include <sys/time.h>

#include <readable.h>

int readable(int fd)
{
    fd_set         rfds;
    struct timeval wait;

    FD_ZERO(&rfds);
    FD_SET(fd, &rfds);

    wait.tv_sec = 0;
    wait.tv_usec = 0;

    return (select(fd + 1, &rfds, NULL, NULL, &wait) == 1) ? 1 : 0;
}
